<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>教师评价系统</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="css/common.min.css" rel="stylesheet">
    <script>
        if(window.top!==window.self){window.top.location=window.location};
    </script>
</head>

<body class="gray-bg">
    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>
                <h1 class="logo-name">X</h1>
            </div>
            <h3>仅限管理员登录</h3>
            <div class="m-t" role="form" action="#">
                <div class="form-group">
                    <input type="text" id="userName" class="form-control" placeholder="用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" id="password" class="form-control" placeholder="密码" required="">
                </div>
                <button id="submit-btn" class="btn btn-primary block full-width m-b">登 录</button>
            </div>
        </div>
    </div>
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>
    <script src="js/jquery.cookie.js"></script>
    <script src="js/common.js"></script>
    <script src="js/plugins/layer/layer.min.js"></script>
    <script>
        $(document).ready(function () {
            window.localStorage.clear();
            $("#submit-btn").click(function () {
                var condition = {
                    userName: $('#userName').val(),
                    passWord: $('#password').val()
                }
                if(!condition.userName || !condition.passWord){
                   return false;
                }
                ajaxCommon({
                    url: "user/login",
                    data: JSON.stringify(condition)
                }, function(obj) {
                    if(obj.code == 200){
                        var data = obj.data;
                        $.cookie("Token",data.token);
                        // 设置User对象保存
                        delete data.token;
                        layer.alert("登录成功~", {
                            skin: 'layui-layer-lan',
                            closeBtn: 0,
                            shift: 1 //动画类型
                        } , function(){
                            window.localStorage.setItem("Admin",JSON.stringify(data));
                            window.location.href = "backIndex.html";
                        });
                    } else if(obj.code == 500){
                        // 账号密码错误
                        commonAlert("账号或密码错误~");
                    }
                }, true);
            });
        })
    </script>
</body>
</html>
